package com.libra.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 
 * ClassName: 消息交换机配置 <br/>
 * @author wangzhch
 * @version 
 * @since JDK 1.8
 */
@Configuration
public class ExchangeConfig {
	/***
	 * 
	 * fanoutExchange:(新建交换机). <br/>
	 *
	 * @author wangzhch
	 * @return
	 * @since JDK 1.8
	 */
	@Bean
	public FanoutExchange fanoutExchange() {
		return new FanoutExchange(QueueConstants.PS_MESSAGE_EXCHANGE);
	}
	/**
	 * 
	 * Amessage:(新建队列). <br/>
	 *
	 * @author wangzhch
	 * @return
	 * @since JDK 1.8
	 */
	@Bean
	public Queue Amessage() {
		return new Queue(QueueConstants.PS_QUEUE_A);
	}
	@Bean
	public Queue Bmessage() {
		return new Queue(QueueConstants.PS_QUEUE_B);
	}
	@Bean
	public Queue Cmessage() {
		return new Queue(QueueConstants.PS_QUEUE_C);
	}
	/**
	 * 
	 * bindingExchangeA:(将队列绑定到交换机). <br/>
	 *
	 * @author wangzhch
	 * @param Amessage
	 * @param fanoutExchange
	 * @return
	 * @since JDK 1.8
	 */
	@Bean
	public Binding bindingExchangeA(Queue Amessage, FanoutExchange fanoutExchange) {
		return BindingBuilder.bind(Amessage).to(fanoutExchange);
	}
	@Bean
	public Binding bindingExchangeB(Queue Bmessage, FanoutExchange fanoutExchange) {
		return BindingBuilder.bind(Bmessage).to(fanoutExchange);
	}
	@Bean
	public Binding bindingExchangeC(Queue Cmessage, FanoutExchange fanoutExchange) {
		return BindingBuilder.bind(Cmessage).to(fanoutExchange);
	}
}
